package com.smilive.start.netty.chat.message;

import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @program: netty
 * @Date: 2022-01-06 9:41
 * @Author: smilive
 * @Description:
 */
@Data
public abstract class Message implements Serializable {

    private int sequenceId;

    private int messageType;

    public abstract int getMessageType();

    private static final Map<Integer,Class<?>> messageClasses = new HashMap<>();

    public static Class<?> getMessageClasses(int messageType){
        return messageClasses.get(messageType);
    }

    public static final int LoginRequestMessage = 0;
    public static final int LoginResponseMessage = 1;
    public static final int ChatRequestMessage = 2;
    public static final int ChatResponseMessage = 3;

    public static final int PinngMessage = 99;

    static {
        messageClasses.put(LoginRequestMessage,LoginRequestMessage.class);
        messageClasses.put(LoginResponseMessage,LoginResponseMessage.class);
        messageClasses.put(ChatRequestMessage,ChatRequestMessage.class);
        messageClasses.put(ChatResponseMessage,ChatResponseMessage.class);
    }


}
